package com.funsport.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.funsport.entity.EventGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 活动分组Mapper接口
 *
 * @author Fun-Sport Team
 */
@Mapper
public interface EventGroupMapper extends BaseMapper<EventGroup> {

    /**
     * 根据活动ID查询所有分组
     */
    @Select("SELECT * FROM event_groups WHERE event_id = #{eventId} ORDER BY group_order")
    List<EventGroup> selectByEventId(@Param("eventId") Long eventId);

    /**
     * 统计活动的分组数量
     */
    @Select("SELECT COUNT(*) FROM event_groups WHERE event_id = #{eventId}")
    int countByEventId(@Param("eventId") Long eventId);
}

